JBoss Community Archive (Read Only)

Scribble

Create the Validator OSGi bundle

This section will explain how to create an OSGi bundle
for a validator from within the Eclipse environment.

The first step is to create the plugin project, using the
New->Project->Plugin Project menu item.

Ensure the 'Create java project' checkbox is ticked, and then
set the source folder to be src/main/java
and set the Target Platform to a
standard 'OSGi Framework'.

Then press the Next button to set some details
associated with the plugin, such as the version, description,
provider, etc.

In this example, we will be registering the validator using
the OSGi registerService method. This is
performed in the bundle activator, whose class is set in the
plugin details. For example, in the start method of the
created Activator, we would have:

	public void start(BundleContext context) throws Exception {
        Properties props = new Properties();
        
        ProtocolValidator validator=new SimpleValidator();
        
        context.registerService(ProtocolValidator.class.getName(), 
				validator, props);
	}		
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 09:37:58 UTC, last content change 2011-05-24 08:36:15 UTC.